#![recursion_limit = "256"]
mod handlers;

use tauri::{
    plugin::{Builder, TauriPlugin},
    Manager, Runtime,
};

/// Initializes the plugin.
pub fn init<R: Runtime>() -> TauriPlugin<R> {
    //
    // tauri::async_runtime::block_on(async move {
    //     //执行数据库脚本
    //     tracing::debug!("执行数据库脚本");
    //     let res = migration::init_database().await;
    //     res
    // })
    // .expect("执行数据库脚本失败！");

    Builder::new("mg-connector")
        .invoke_handler(tauri::generate_handler![
            handlers::open,
            handlers::query,
            handlers::query_one,
            handlers::execute,
            handlers::close
        ])
        .setup(|app, plugin| {
            app.manage(handlers::ContextState::default());
            Ok(())
        })
        .build()
}
